<template>
  <div>
    <div class="bg">
      <!-- <div class="info">
        <img src="http://static.shonemore.com/logo.png" style="width: 13rem; vertical-align: bottom; margin-bottom: 2.5rem;"/>
        <div class="info_title">事中事后监管系统</div>
        
      </div> -->
      <!-- <div class="loginBox">
        <div class="title">登录</div>
        <div class="name">
          <input type="text" placeholder="请输入账号" v-model="item.name"></input>
        </div>
        <div class="password">
          <input type="password" placeholder="请输入密码" v-model="item.password"></input>
        </div>
       
        <el-button class="loginButton" type="primary" round @click="toLogin" style="height: 2.75rem; border-radius: 1.375rem">立即登录</el-button>
        
      </div> -->
      <div class="content">
        <div class="login_icon">
          <img
            src="http://static.shonemore.com/company/login_icon.png?imageView2/0/q/75"
            alt=""
          />
        </div>
        <div class="login_info">
          <div class="title">
            <div class="ch">悦客VIP后台管理系统</div>
          
            <!-- <div class="en">PUBLIC PLACE ARCHIVES AND PROCESS SUPERVISION SYSTEM</div> -->
          </div>
          <div class="name" >
            <i style="font-size:20px" class="el-icon-user"></i>
          <input  type="text" placeholder="请输入账号" v-model="item.name" @keyup.enter="toLogin" ></input>
        </div>
        <div class="password">
          <i style="font-size:20px" class="el-icon-lock"></i>
          <input  :type="inputType" placeholder="请输入密码" v-model="item.password" @keyup.enter="toLogin"></input>
          <i style="font-size:10px" class="el-icon-view" @click="setInputType"></i>
        </div>
        
         <el-button class="loginButton" type="primary" round @click="toLogin" style="width:18rem;height: 3.25rem; border-radius: 1.875rem;font-size:1.4rem;margin-left:2rem">登录</el-button>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "login",
  data() {
    return {
      inputType: "password",
      item: {},
    };
  },
  created() {},
  mounted() {},
  updated() {},
  methods: {
    setInputType() {
      let inputType = this.inputType;
      if (inputType == "password") {
        inputType = "text";
      } else {
        inputType = "password";
      }
      this.inputType = inputType;
    },

    //去登录
    toLogin() {
      this.global.httpRequest("login", this.item, "post").then((res) => {
        if (res.code == 0) {
          let data = res.data;
          let type = data.type;
          localStorage.setItem("token", data.token);
          localStorage.setItem("name", data.name);
          localStorage.setItem("admin_type", type);
          localStorage.setItem("refresh", '');
         
           this.$router.push({ path: "/redirect" })
        }
      });
    },
    //存用户cookie信息
    setUserCookie() {
      let d = new Date();
      d.setTime(d.getTime() + 24 * 60 * 60 * 1000 * 3); //保存3天
      //字符串拼接cookie
      document.cookie =
        "userName" + "=" + this.userName + ";path=/;expires=" + d.toGMTString();
      document.cookie =
        "userPassword" +
        "=" +
        this.userPassword +
        ";path=/;expires=" +
        d.toGMTString();
    },

    //微信登录
    toWXLogin() {
      this.global.postRequire("api/admin/wxLoginUri", {}).then((res) => {
        window.location.href = res.data.data;
      });
    },
  },
};
</script>

<style scoped>
.bg {
  background: url("http://static.shonemore.com/company/login_bg.png?imageView2/0/q/75");
  background-size: cover;
  width: 62.375%;
  height: 100%;
  padding-right: 22%;
  padding-left: 15.625%;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 200;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.info {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.info_title {
  line-height: 2.75rem;
  color: #fff;
  font-size: 2.25rem;
  font-weight: 600;
}
.loginBox {
  width: 19.125rem;
  padding: 3.875rem 3.75rem 2.5rem;
  background: #fff;
  border-radius: 2.5rem;
}
.title {
  width: 100%;
  text-align: center;
  margin-bottom: 2.4rem;
}
.title .ch {
  font-size: 1.85rem;
  color: #34373d;
  font-weight: bold;
  letter-spacing: 0.2rem;
}

.title .en {
  margin-top: 1rem;
  font-size: 0.75rem;
  color: #d3d3d3;
}

.name {
  width: 80%;
  border-bottom: 0.0625rem #dde2ea solid;
  /* margin-bottom: 3.125rem; */
  margin: 0 0 1.525rem 2rem;
}
.name > input {
  border: none;
  outline: none;
  margin-bottom: 0.35rem;
  font-size: 0.875rem;
  width: 80%;
}
.password {
  width: 80%;
  border-bottom: 0.0625rem #dde2ea solid;
  margin: 0 0 1.875rem 2rem;
}
.password > input {
  border: none;
  outline: none;
  margin-bottom: 0.35rem;
  font-size: 0.875rem;
  width: 80%;
}
.loginButton {
  width: 100%;
  margin-top: 3.75rem;
  margin-bottom: 3.375rem;
  font-size: 0.875rem;
}
.otherLogin {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
}
.otherLogin > img {
  width: 2rem;
  vertical-align: bottom;
}
.otherLogin > span {
  font-size: 0.75rem;
  color: #9ca4b1;
  margin-top: 0.875rem;
}

.content {
  display: flex;
  width: 1300px;
  height: 650px;
  background: #fff;
  margin: 0 auto;
  border-radius: 2%;
  align-items: center;
  justify-content: space-around;
}
.login_icon {
  position: absolute;
  left: 8%;
  width: 834px;
  height: 794px;
}
.login_icon img {
  width: 100%;
  height: 100%;
}
.login_info {
  margin: 0 0 50px 600px;
  z-index: 1000;
}
.login_info .title {
  font-weight: bold;
  font-size: 1.55rem;
}
</style>
